package com.example.musicdemo.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.example.musicdemo.R
import com.example.musicdemo.model.Music
import com.example.musicdemo.util.StringUtil
import kotlinx.android.synthetic.main.item_search.view.*

class SearchItemView:RelativeLayout {
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {
        val inflate = View.inflate(context, R.layout.item_search, this)
    }

    fun setData(song: Music){
        song?.apply {
            tv_singer_search.text = singer
            tv_time_song_search.text = StringUtil.parseDuration(this.duration)
            tv_song_search.text = this.song
        }
    }
}